﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Runtime.InteropServices;

public class WebAudioManager {

	// api implemented in javascript
	[DllImport("__Internal")]
	private static extern void LoadSound(string name);

	[DllImport("__Internal")]
	private static extern void PlaySound(string name, int loop);

	private static WebAudioManager internalInstance;

	private WebAudioManager() {
	}

	public static WebAudioManager instance{
		get {
			if (internalInstance == null) {
				internalInstance = new WebAudioManager ();
			}
			return internalInstance;
		}
	}

	public void RequestSound(string name) {
		LoadSound (name);
	}
		
	public void PlaySoundImmdiately(string name, int loop) {
		PlaySound (name, loop);
	}
}
